//买卖股票的最佳时机二  力扣122
//贪心   局部最优解：只购买有增益的股票，即收集所有正利润
class Solution {
public:
	int maxProfit(vector<int>& prices) {
		long long ans = 0;
		for(int i = 0; i < prices.size() - 1; i++)
		{
			//if(prices[i] < prices[i+1]) ans += prices[i+1] - prices[i];
			ans += max(prices[i+1] - prices[i],0);
		}
		return ans;
	}
};
